<?php

namespace app\model;

class MenuModel extends BaseModel
{
    protected $table = 'menu';

    public function getRoleMenuList($role_id,$where=[],$root=0){
        if($where){
            $this->where($where);
        }
        if($root){
            $join = [
                ['re_role rm','rm.menu_id = menu.id and rm.role_id ='.$role_id,'LEFT'],
            ];
        }else{
            $join = [
                ['re_role rm','rm.menu_id = menu.id and rm.role_id ='.$role_id,'LEFT'],
            ];
        }

        $this->alias('menu')
            ->field('menu.*,rm.role_id ,rm.menu_id as is_menu ')
            ->join($join);
        $this->order('menu.id asc,list_order desc');
        return $this->select();
    }

}